﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Library.Wcf;
using log4net;

namespace MvcApplication3.Controllers
{
    public class HomeController : Controller
    {
        private static readonly ILog Log = LogManager.GetLogger("HomeController");

        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            if(Request.IsAuthenticated)
            {
                Log.Info("About_start");
                var deviceClient = new DeviceWcfClient("http://pi:4321/Device");
                var devices = deviceClient.GetAllWithData();

            //                var client = new UserWcfClient("http://pi:4321/User");
            //User user = client.ValidateUser(model.UserName, model.Password);


                Log.Info("About_end");
                deviceClient.Close();

                return View("AboutAuthenticated", devices);

            }
            return View();
        }
    }
}
